<?php
/**
 * Cube PHP Framework
 * 
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 * 
 * @author Dillen / Steffen
 */

namespace Library\Web;

/**
 * @class Library.Web.WebApplication
 * 
 * View class
 */
class WebApplication
{
	/**
	 * @property {Library.Application} application
	 * @readonly
	 */
	public $application;
	
	/**
	 * Sessions array
	 * 
	 * @property {Library.Web.Sessions} sessions
	 */
	public $sessions;
	
	/**
	 * Cookies array
	 * 
	 * @property {Library.Web.Cookies} cookies
	 * @var Cookies
	 */
	public $cookies;
	
	/**
	 * Post array
	 * 
	 * @property {Library.Web.Post} post
	 * @var Post
	 */
	public $post;
	
	/**
	 * Get array
	 * 
	 * @property {Library.Web.Get} get
	 * @var Get
	 */
	public $get;
	
	/**
	 * Response class
	 * 
	 * @property {Library.Web.Response} response
	 */
	public $response;
	
	/**
	 * Server variables array
	 * 
	 * @property {Array} serverVariables
	 */
	protected $serverVariables;
    
    private static $_firstInstance;
	
	/**
	 * Constructor
	 *
	 * Set up the web application class
	 * 
	 * @method __construct
	 * @param {Library.Application} $application Application instance
	 */
	public function __construct()
	{
		$this->cookies = new Cookies();
		$this->sessions = new Sessions();
		$this->response = new Response();
		$this->post = new Post();
		$this->get = new Get();
	}
    
    public static function getInstance()
    {
        if (self::$_firstInstance == null)
        {
            self::$_firstInstance = new WebApplication();
        }
        
        return self::$_firstInstance;
    }
}